package com.anti.modular.bus.busprintsettings.controller;

import com.anti.commom.annotation.BusinessLog;
import com.anti.commom.annotation.Permission;
import com.anti.commom.enums.LogAnnotionOpTypeEnum;
import com.anti.commom.api.Result;
import com.anti.jdbc.support.page.PageParam;
import com.anti.modular.bus.busprintsettings.param.BusPrintSettingsParam;
import com.anti.modular.bus.busprintsettings.service.BusPrintSettingsService;
import org.springframework.web.bind.annotation.*;
import org.springframework.validation.annotation.Validated;

import javax.annotation.Resource;

/**
 * 打印設置控制器
 *
 * @author anti
 * @date 2021-04-11 09:10:50
 */
@RestController
@RequestMapping("busPrintSettings")
public class BusPrintSettingsController {

    @Resource
    private BusPrintSettingsService busPrintSettingsService;

    /**
     * 查询打印設置
     *
     * @author anti
     * @date 2021-04-11 09:10:50
     */
    @GetMapping("page")
    @BusinessLog(title = "打印設置_查询", opType = LogAnnotionOpTypeEnum.QUERY)
    public Result page(PageParam pageParam, BusPrintSettingsParam busPrintSettingsParam) {
        return Result.data(busPrintSettingsService.page(pageParam,busPrintSettingsParam));
    }

    /**
     * 添加打印設置
     *
     * @author anti
     * @date 2021-04-11 09:10:50
     */
    @Permission
    @PostMapping("add")
    @BusinessLog(title = "打印設置_增加", opType = LogAnnotionOpTypeEnum.ADD)
    public Result add(@RequestBody @Validated(BusPrintSettingsParam.add.class) BusPrintSettingsParam busPrintSettingsParam) {
            busPrintSettingsService.add(busPrintSettingsParam);
        return Result.success("新增成功");
    }

    /**
     * 删除打印設置
     *
     * @author anti
     * @date 2021-04-11 09:10:50
     */
    @Permission
    @PostMapping("delete")
    @BusinessLog(title = "打印設置_删除", opType = LogAnnotionOpTypeEnum.DELETE)
    public Result delete(@RequestBody @Validated(BusPrintSettingsParam.delete.class) BusPrintSettingsParam busPrintSettingsParam) {
            busPrintSettingsService.delete(busPrintSettingsParam);
        return Result.success("删除成功");
    }

    /**
     * 编辑打印設置
     *
     * @author anti
     * @date 2021-04-11 09:10:50
     */
    @Permission
    @PostMapping("edit")
    @BusinessLog(title = "打印設置_编辑", opType = LogAnnotionOpTypeEnum.EDIT)
    public Result edit(@RequestBody @Validated(BusPrintSettingsParam.edit.class) BusPrintSettingsParam busPrintSettingsParam) {
            busPrintSettingsService.edit(busPrintSettingsParam);
        return Result.success("修改成功");
    }

    /**
     * 查看打印設置
     *
     * @author anti
     * @date 2021-04-11 09:10:50
     */
    @GetMapping("busPrintSettingsOne")
    @BusinessLog(title = "打印設置_查看", opType = LogAnnotionOpTypeEnum.DETAIL)
    public Result busPrintSettingsOne() {
        return Result.data(busPrintSettingsService.detail());
    }

    /**
     * 打印設置列表
     *
     * @author anti
     * @date 2021-04-11 09:10:50
     */
    @GetMapping("list")
    @BusinessLog(title = "打印設置_列表", opType = LogAnnotionOpTypeEnum.QUERY)
    public Result list(BusPrintSettingsParam busPrintSettingsParam) {
        return Result.data(busPrintSettingsService.list(busPrintSettingsParam));
    }

}
